import React, { Component } from 'react'
import { IndexLink, Link } from 'react-router'

import { Menu, Icon } from 'antd';
const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;
import './nav.scss'

export default class Nav extends Component {
    constructor(porps) {
        super(porps);
        this.state = {
            current: this.props.pathname == '/' ? '/home' : this.props.pathname
        }
    }

    handleClick(e) {
        console.log('click ', e);
        this.setState({
            current: e.key,
        });
    }

    render() {
        return (
            <Menu onClick={this.handleClick.bind(this)}
                  selectedKeys={[this.state.current]}
                  mode="inline"
                  className="nav-wrapper"
            >
                <Menu.Item key="/home">
                    <IndexLink to="/">首页</IndexLink>
                </Menu.Item>
                <SubMenu key="sub1" title={<span>权限管理</span>}>
                    <Menu.Item key="/privilegeWhite">
                        <Link to="/privilegeWhite">白名单</Link>
                    </Menu.Item>
                    <Menu.Item key="/privilegeApp">
                        <Link to="/privilegeApp">应用管理</Link>
                    </Menu.Item>
                    <Menu.Item key="/privilegeRole">
                        <Link to="/privilegeRole">角色管理</Link>
                    </Menu.Item>
                    <Menu.Item key="/privilegeUser">
                        <Link to="/privilegeUser">用户管理</Link>
                    </Menu.Item>
                    <Menu.Item key="/privilegeRight">
                        <Link to="/privilegeRight">权限管理</Link>
                    </Menu.Item>
                    <Menu.Item key="/privilegeArea">
                        <Link to="/privilegeArea">区域管理</Link>
                    </Menu.Item>
                    <Menu.Item key="/privilegeLog">
                        <Link to="/privilegeLog">操作日志</Link>
                    </Menu.Item>
                </SubMenu>
                <SubMenu key="sub2" title={<span>应用扩展</span>}>
                    <Menu.Item key="/extendParam">
                        <Link to="/extendParam">参数设置</Link>
                    </Menu.Item>
                    <Menu.Item key="/extendStation">
                        <Link to="/extendStation">服务站设置</Link>
                    </Menu.Item>
                </SubMenu>
                <SubMenu key="sub3" title={<span>账号设置</span>}>
                    <Menu.Item key="/account">
                        <Link to="/accountPassword">修改密码</Link>
                    </Menu.Item>
                </SubMenu>
            </Menu>
        )
    }
}